import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);
export default new Vuex.Store({
	state: {
		token:sessionStorage.getItem('token'),
		userInfo:null,
		crumbList: []
	},
	mutations: {
		logout(state, user) {
			state.token = null
			state.userInfo = null;
			sessionStorage.removeItem("userInfo");
			sessionStorage.removeItem("token");
		},
		setToken: (state, data) => {
			sessionStorage.setItem('token', data)
			state.token = data;
		},
		setUserInfo: (state, data) => {
			sessionStorage.setItem('userInfo', data)
			state.userInfo = data;
		},
		setCrumbList(state, list) {
			state.crumbList = list[1];
		}
	}
})
